<script lang="ts" setup>
	import { ref, reactive, watch } from 'vue'
	import {
		onLoad,
		onUnload,
		onReachBottom
	} from '@dcloudio/uni-app';
	import {
		getCurrentInstance
	} from 'vue'
	import {
		userStore
	} from '@/pinia';
	import {
		useRouter
	} from 'uni-mini-router';
	const {
		proxy,
	} = getCurrentInstance()
	const userStoreInfo = userStore();
	let router = useRouter()
	let searchWord = ref('')
	let type = ref()
	onLoad((options) => {
		console.log(options);
		searchWord.value = options.value
		type.value = options.type
		// uni.setNavigationBarTitle({
		// 	title: options.name
		// })
		getList()
	})
	let pageNum = ref(1)
	let goodsList = ref([])
	onReachBottom(() => {
		pageNum.value++
		getList()
	})
	const searchNow = () => {
		pageNum.value = 1
		goodsList.value = []
		getList()
	}
	const getList = () => {
		proxy.$req('GET', proxy.$api.commonGoodsList, {
			name: searchWord.value,
			isType: type.value,
			pageNo: pageNum.value,
			pageSize: '14'
		}).then((res) => {
			console.log(res);
			goodsList.value = goodsList.value.concat(res.result.records)
		})
	}
</script>
<template>
	<view class="navbar">
		<u-navbar :placeholder="true" leftText="" title="" auto-back>
			<template #center>
				<view style="width: 70%;">
					<u-search placeholder="请输入" v-model="searchWord" :showAction="false" @search="searchNow"></u-search>
				</view>
			</template>
			<template #right>
				<text @click="router.back()">取消</text>
			</template>
		</u-navbar>
	</view>
	<view class="aa" v-if="goodsList.length>0">
		<shop-goods-card :list="goodsList"></shop-goods-card>
	</view>
	<view class="" style="margin-top: 150rpx;" v-else>
		<u-empty mode="search" icon="/static/images/noSearch.png">
		</u-empty>
	</view>
</template>
<style lang="scss">
	page {
		background-color: #fafafa;
	}

	view {
		box-sizing: border-box;
	}

	.aa {
		width: 686rpx;
		padding: 32rpx;
		background: #FFFFFF;
		box-shadow: 8rpx 8rpx 32rpx 0rpx rgba(0, 0, 0, 0.04);
		border-radius: 24rpx;
		border: 2rpx solid #FFFFFF;
		margin: 32rpx auto 0;
	}
</style>